
from django_filters.filters import *

from django_filters.rest_framework import FilterSet

from apps.gzde.models import *


class GoodsFilter(FilterSet):
    """
    商品过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Goods
        fields = ['category','add_time_begin','add_time_end']


class GoodsCategoryFilter(FilterSet):
    """
    商品分类管理过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = GoodsCategory
        fields = ['add_time_begin','add_time_end']


class AttachmentFilter(FilterSet):
    """
    附件管理过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = Attachment
        fields = ['name','type','add_time_begin','add_time_end']


class IndexBannerFilter(FilterSet):
    """
    附件管理过滤
    """
    add_time_begin = DateFilter(field_name='create_time', lookup_expr='gte', label='开始日期')
    add_time_end = DateFilter(field_name='create_time', lookup_expr='lt', label='结束日期')

    class Meta:
        model = IndexBanner
        fields = ['name','add_time_begin','type','add_time_end']